package com.atguigu.bean;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 读取kafka.properties配置文件
 *
 * Project: DXXM
 * Package: com.atguigu
 * Version: 1.0
 * <p>
 * Created by  WangJX  on 2020/2/20 20:45
 */
public class PropertiesUtil {
    public static Properties properties = null;
    static{
        try {
            // 加载配置属性
            InputStream inputStream = ClassLoader.getSystemResourceAsStream("kafka.properties");
            properties = new Properties();
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getProperty(String key){
        return properties.getProperty(key);
    }

    public static void main(String[] args) {
        String s = PropertiesUtil.getProperty("bootstrap.servers");
        System.out.println(s);
    }
}